package com.langsin.QueueDemo;

/**
 * @Auther: MFM
 * @Date: 2021/7/16 - 07 - 16 - 21:54
 * @version: 1.0
 */

public class ArrayQueue<E> implements Queue<E> {

    Array<E> arrayQueue;

    //带参构造函数
    public ArrayQueue(int capacity) {
        arrayQueue = new Array<>(capacity);
    }

    //无参构造函数
    public ArrayQueue() {
        arrayQueue = new Array<>();
    }

    //入队
    @Override
    public void enQueue(E e) {
        arrayQueue.addLast(e);
    }

    //出队
    @Override
    public E deQueue() {
        return arrayQueue.removeFirst();
    }

    //获得队首
    @Override
    public E getFront() {
        return arrayQueue.get(0);
    }

    //获取队内元素总量
    @Override
    public int getSize() {
        return arrayQueue.getSize();
    }

    //判断是否为空
    @Override
    public boolean isEmpty() {
        return arrayQueue.isEmpty();
    }

    //获取总量
    public int getCapacity() {
        return arrayQueue.getCapacity();
    }

    @Override
    public String toString() {
        return "Queue：出队" + arrayQueue + "入队";
    }
}
